Rails.application.routes.draw do
  namespace :api do
    namespace :v1 do
      resources :swipers
      resources :advertisements
      resources :regions
      resources :shop_categories do
        collection do
          get :clearance
        end
      end
      resources :brands do
        member do
          get :spus
        end
      end
      resources :channels
      resources :spus
      resources :skus
      resources :orders do
        member do
          post :complete
          post :cancel
          post :refund
          post :after_sale
          get :success
          get :evaluate
        end
        collection do
          post :notify
          post :alipay_notify
        end
      end
      resources :order_items do
        collection do
          get :after_sales
        end
        member do
          post :after_sale
        end
      end
      resources :users do
        collection do
          post :reset_password
          post :reset_phone
          post :share
        end
      end
      resources :sessions do
        collection do
          get   :wechat
        end
      end
      resources :identify_codes
      resources :addresses
      resources :feedbacks
      resources :favorites
      resources :shops do
        member do
          get :spus
        end
        collection do
          get :near
          get :validate_info
          post :validate
        end
      end
      resources :pay
      resources :comments
      resources :comment_pictures
      resources :activities
      resources :user_search_keys
      resources :spu_tracks
      resources :seckill_spus
      resources :seckill_times
      resources :coupons do
        collection do
          get :categories
        end
      end
      resources :user_coupons
      resources :refund_reasons
      resources :refund_pictures
      resources :actives
      resources :notifications
      resources :feedbacks
      resources :express_tracks
      resources :deposit_preferences
      resources :deposits do
        collection do
          post :pay
          post :notify
          post :alipay_notify
        end
      end
      resources :settings
      resources :hot_tags
      resources :shop_chats
      resources :chat_windows
      resources :chat_messages
      resources :memberships
      resources :topics
      resources :topic_pictures
      resources :scratch_card_awards
      resources :user_scratch_card_awards
      resources :bonus_records
      
      get '/pages/categories', to: 'pages#categories'
      get '/pages/brands_wall', to: 'pages#brands_wall'
      get '/pages/recommend', to: 'pages#recommend'
      get '/pages/brands', to: 'pages#brands'
      get '/pages/seckills', to: 'pages#seckills'
      get '/pages/search', to: 'pages#search'
      get '/pages/headlines', to: 'pages#headlines'
      get '/pages/clearance', to: 'pages#clearance'
      get '/pages/notices', to: 'pages#notices'
      get '/pages/update_region', to: 'pages#update_region'
    end
  end

  namespace :mobile do
    resources :seckills
    resources :chats
    resources :service_terms
    resources :invites do
      collection do
        get :index_in_app
      end
    end
    resources :scratch_cards
    get '/pages/bonus_description', to: 'pages#bonus_description'
    get '/pages/term_of_service', to: 'pages#term_of_service'
  end

  namespace :shop do
    resources :pictures
    resources :sessions
    resources :activities
    resources :shops
    resources :shopers
    resources :orders do
      resources :express_tracks
    end
    resources :order_items do
      member do
        post :refund
      end
    end
    resources :shop_categories do
      resources :spus
    end
    resources :spu_categories
    resources :spus do
      resources :spu_images
      resources :spu_details
      resources :spu_parameters
      resources :skus
      resources :spu_coupons

      member do
        get :orders

        post :check
        post :trash
        post :published
      end
    end
    resources :skus
    resources :seckill_spus
    resources :coupons
    resources :settles
    resources :fare_templates do
      resources :fare_modes
    end
    resources :logistics_companies
    resources :shop_chats do
      resources :chat_windows
    end
    resources :home
    resources :chat_messages

    get 'register', to: 'shopers#new'
    get 'login', to: 'sessions#new'
    root "home#index"
  end

  namespace :admin do
    resources :admins
    resources :swipers
    resources :advertisements
    resources :settings
    resources :sessions
    resources :activities
    resources :seckill_spus
    resources :seckill_times
    resources :shops do
      resources :shopers

      member do
        get :reporter
      end
    end
    resources :shop_categories do
      resources :option_types
      resources :spus
      resources :shop_category_brands
    end
    resources :channels
    resources :brands
    resources :option_types do
      resources :option_values
    end
    resources :option_values
    resources :spus do
      resources :skus

      member do
        post :handpick
        post :show_index
      end
    end
    resources :skus
    resources :users do
      resources :bonus_records
    end
    resources :service_items
    resources :coupons
    resources :logistics_companies
    resources :settles
    resources :refund_reasons
    resources :shop_types
    resources :actives do
      resources :active_shop_categories
    end
    resources :feedbacks
    resources :deposit_preferences
    resources :scratch_card_awards
    resources :user_scratch_card_awards
    resources :hot_tags
    resources :memberships
    resources :topics
    resources :home

    get 'register', to: 'admins#new'
    get 'login', to: 'sessions#new'
    root "home#index"
  end

  mount ExceptionTrack::Engine => "/exception-track"
end
